import request from '@/utils/request'

function url(u) {
  const prefix = '/device'
  return `${prefix}${u || ''}`
}

export function findAllDevices() {
  return request({
    url: url('/select'),
    method: 'get'
  })
}

export function addDevice(device) {
  return request({
    url: url('/add'),
    method: 'post',
    data: device
  })
}

export function updateDevice(device) {
  return request({
    url: url('/update'),
    method: 'post',
    data: { device }
  })
}

export function lendDevice(deviceId) {
  return request({
    url: url('/lend'),
    method: 'get',
    params: { deviceId }
  })
}

export function returnDevice(deviceId) {
  return request({
    url: url('/return'),
    method: 'get',
    params: { deviceId }
  })
}

export function deleteDevice(device) {
  return request({
    url: url('/delete'),
    method: 'get',
    params: { device }
  })
}
